package com.kfm.loginIp.config;

import com.kfm.loginIp.interceptor.APIAccessInterceptor;
import com.kfm.loginIp.interceptor.LoginErrorInterceptor;
import com.kfm.loginIp.interceptor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Aurora雪
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginErrorInterceptor loginErrorInterceptor;
    @Autowired
    private APIAccessInterceptor apiAccessInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器
        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**").excludePathPatterns("/css/**", "/js/**", "/images/**","/admin/**","/component/**","/config/**");

        registry.addInterceptor(loginErrorInterceptor).addPathPatterns("/login", "/").excludePathPatterns("/css/**", "/js/**", "/images/**","/admin/**","/component/**","/config/**");

        registry.addInterceptor(apiAccessInterceptor).addPathPatterns("/**").excludePathPatterns("/css/**", "/js/**", "/images/**","/admin/**","/component/**","/config/**");
    }

}
